#include "Animation.h"


Animation::Animation(void)
{
	timeOfGame = 0;
	timeDelay = 0.2;
	index = 0;
	position.x = 0;
	position.y = 0;
}

Animation::Animation(Sprite _sprite, SDL_Renderer* _pRenderer)
{
	m_sprite = _sprite;
	m_pRenderer = _pRenderer;
	TheTextureManager::Instance()->add(m_sprite, _pRenderer);
	timeOfGame = 0;
	timeDelay = 0.2;
	index = 0;
	position.x = 0;
	position.y = 0;
}

Animation::~Animation(void)
{
}

void Animation::setPosition(Point _pos)
{
	position.x = _pos.x;
	position.y = _pos.y;
}

void Animation::setTimeDelay(float _timeDelay)
{
	timeDelay = _timeDelay;
}

void Animation::resumeAnimation()
{
}

void Animation::stopAnimation()
{
}

void Animation::update(float &dt)
{
	timeOfGame += dt;
	if (timeOfGame > timeDelay)
	{
		index++;
		timeOfGame -= timeDelay;
	}
	if (index >= m_sprite.getNumSprite())
	{
		index = 0;
	}
}

void Animation::rederAnimation()
{
	TheTextureManager::Instance()->drawParallax(m_sprite, index, m_pRenderer);	
}